package com.zlm.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 职位属性枚举
 * @Author: duyufu
 * @Date: 2019/4/26 17:15
 */
public enum PositionStyleEnum {

    POST_STYLE_1(1,"委托招聘"),
    POST_STYLE_2(2,"服务外包"),
    POST_STYLE_3(3,"劳务派遣");

    private Integer code;
    private String name;

    private PositionStyleEnum(Integer code, String name){
        this.code=code;
        this.name=name;
    }

    //把枚举转成json
    public static String getJsonString(){
        StringBuilder builder = new StringBuilder("{");
        for (PositionStyleEnum positionStyleEnum:PositionStyleEnum.values()) {
            builder.append("\""+positionStyleEnum.getCode()+"\":\""+positionStyleEnum.getName()+"\"," );
        }
        String json=builder.substring(0, builder.length()-1)+"}";
        return json;

    }
    public static List getIsTravel(){
        List list = new ArrayList();
        Map<String,Object> map;
        for (PositionStyleEnum positionStyleEnum:PositionStyleEnum.values()) {
            map= new HashMap<String, Object>();
            map.put("code", positionStyleEnum.getCode());
            map.put("name", positionStyleEnum.getName());
            list.add(map);
        }
        return list;

    }

    public static  String getNameByCode(Integer code){
        for (PositionStyleEnum positionStyleEnum:PositionStyleEnum.values()) {
            if(code.equals(positionStyleEnum.getCode())){
                return positionStyleEnum.getName();
            }
        }
        return null;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
